package VN.EDU.IMIC.DEVELOPER.LETRONGKHANH.JDBC_DEMO;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Types;

import com.sqlserver.imic.edu.vn.ConnectionManager.SqlConnection;

public class CallableStament_demo03 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Connection objConnection;
		SqlConnection obj = new SqlConnection();
		
	try {
		objConnection = obj.OpenConnection("DESKTOP-F43Q9GJ", "sa", "12345", "QLBH", 1433); 
		if(!objConnection.isClosed()){
			ResultSet objRs;
			CallableStatement objCmst;
		objCmst = objConnection.prepareCall("{? = call Y2015JC72USER(?,?)}");
		objCmst.registerOutParameter(1, Types.TINYINT);
		objCmst.setString("TenGiaoDich", "VINAMILK");
		objCmst.setString("DiaChi", "Hà Nội");
		objCmst.execute();
		short shResult = objCmst.getShort(1);
		if(shResult>0){
			System.out.println("co ton tai tai khoan");
		}else {
			System.out.println("khong ton tai tai khoan");
		}
		}else{
			System.out.println("Dang nhap that bai");
		}
	}

	catch (Exception e) {
		e.printStackTrace();
	}

}
}
